home *** CD-ROM | disk | FTP | other *** search
- GFA-Basic Documentation for STiK v1.08
- by Lonny Pursell
- (C)1997 by Lonny Pursell and ENCOM
- All rights reserved.
- Date: 6/8/1997
- E-Mail: atari@bright.net
-
- ===========================================================================
- The purpose of this document is to show how to access STiK from GFA-Basic.
- It does not explain internet protocols and how they work. Protocols such
- as POP3, HTTP, TELNET, and FTP are not covered and anyone wanting to
- implement such protocols should find the proper RFC or document. Again
- this document only details the use of GFA-Basic to access the main STiK
- functions.
-
- The GFA-Basic version of the STiK devkit was designed to follow the 'C'
- devkit as closely as possible. Do to the differences in the two languages
- some things are a bit different. For the most part the 'C' documention
- is very accurate and may help shed some light on some of the STiK calls.
- I suggest you at least look over the 'C' version of the devkit if you are
- curious about STiK or if you get confused and need further information.
-
- If a parameter is not explained it should be left as is. The variable
- types used are very important so don't change them! None of the KRxx
- functions are detailed as they should be avoided. The UDP_xx functions
- should not be used unless you know what you are doing. Functions not
- listed here are ones I don't use or considered not that important. If you
- understand the ones listed the others should be easy enough to figure out
- on your own. It's worth noting that I used GFA-Basic 3.6TTe to make the
- STiK library so if lesser versions complain about the syntax that is
- probably the cause.
-
- ---------------------------------------------------------------------------
- FUNCTION: init_stik()
- PURPOSE: must be called once to allow STiK access from GFA-Basic
- SYNTAX: result&=@init_stik
- OUTPUT: result& - if 0 then STiK is loaded and can be accessed
- if other than 0 then an error occured
- 0 - STiK access is granted
- -1 - SYSTEM HAS NO COOKIE JAR
- -2 - STiK NOT FOUND
- -3 - STiK IS DISABLED
- -4 - STiK MAGIC NOT FOUND
- -5 - TRANSPORT LAYER NOT LOADED
- NOTE: not an actual STiK call but interfaces STiK with GFA-Basic
- ---------------------------------------------------------------------------
- FUNCTION: resolve()
- PURPOSE: converts a domain name into an IP address
- SYNTAX: result&=@resolve(domain$,0,V:ip%,1)
- INPUT: domain$ - the site you want to convert into an IP address
- V:ip% - address of where we want to store the IP address
- OUTPUT: result& - if positive no error occured
- if negative an error occured
- ip% - will contain the IP address when the function returns
- NOTE: if the IP address is known then resolve() in not really needed
- ---------------------------------------------------------------------------
- FUNCTION: tcp_open()
- PURPOSE: opens a connection
- SYNTAX: result&=@tcp_open(ip%,port%,0,bufsize&)
- INPUT: ip% - IP address of site to connect to
- port% - port number (depends on protocol used)
- bufsize& - amount of ram STiK should allocate for the connection
- OUTPUT: result& - if positive it's the handle assigned to the connection
- if negative an error occured
- NOTE: result&=@tcp_open(0,0,0,bufsize&) !this would be a listen socket
- buffer size depends on the protocol you are using
- the ram is allocated from STiK's internal ram
- STiK's internal ram size is set with the ALLOCMEM= tag
- ---------------------------------------------------------------------------
- FUNCTION: tcp_send()
- PURPOSE: send data across a connection
- SYNTAX: result&=@tcp_send(cn&,buf%,len&)
- INPUT: cn& - connection handle returned from tcp_open()
- buf% - address of memory buffer containing data to be sent
- len& - how many bytes should be sent
- OUTPUT: result& - if positive no error occured
- if negative an error occured
- ---------------------------------------------------------------------------
- FUNCTION: tcp_close()
- PURPOSE: close an open connection
- SYNTAX: result&=@tcp_close(cn&,timeout&)
- INPUT: cn& - connection handle returned from tcp_open()
- timeout& - timeout value in seconds
- OUTPUT: result& - if positive no error occured
- if negative an error occured
- NOTE: the ram allocated for a connection is freed when it's closed
- ---------------------------------------------------------------------------
- FUNCTION: tcp_wait_state()
- PURPOSE: waits for a connection to reach a state within a time limit
- SYNTAX: result&=@tcp_wait_state(cn&,state&,timeout&)
- INPUT: cn& - connection handle returned from tcp_open()
- state& - connection state you want to wait for
- refer to the connection state list below
- timeout& - timeout value in seconds
- OUTPUT: result& - if positive no error occured
- if negative an error occured
- NOTE: should probably not be used on listen sockets
- ---------------------------------------------------------------------------
- FUNCTION: cnbyte_count()
- PURPOSE: returns the number of bytes that came in on a given connection
- SYNTAX: count&=@cnbyte_count(cn&)
- INPUT: cn& - connection handle returned from tcp_open()
- OUTPUT: count& - if positive it's the number bytes that came in
- if negative an error occured
- NOTE: a return value of 0 simply means no data waiting
- ---------------------------------------------------------------------------
- FUNCTION: cnget_char()
- PURPOSE: fetches a single byte from a given connection
- SYNTAX: char&=@cnget_char(cn&)
- INPUT: cn& - connection handle returned from tcp_open()
- OUTPUT: char& - if positive it's a byte that came in
- if negative an error occured
- NOTE: depending on your application this might be too slow
- ---------------------------------------------------------------------------
- FUNCTION: cnget_block()
- PURPOSE: fetches a block of bytes from a given connection
- SYNTAX: result&=@cnget_block(cn&,buf%,len&)
- INPUT: cn& - connection handle returned from tcp_open()
- buf% - memory address to put incoming data in
- len& - number of bytes to fetch from the connection
- OUTPUT: result& - if positive it should be the same as len& going in
- if negative an error occured
- NOTE: much faster than cnget_char() but harder to use
- ---------------------------------------------------------------------------
- FUNCTION: cngetinfo()
- PURPOSE: returns information about a given connection
- SYNTAX: pointer%=@cngetinfo(cn&)
- INPUT: cn& - connection handle returned from tcp_open()
- OUTPUT: pointer% - address of structure containing connection information
- refer to table below for a list
- NOTE: as of STiK version 1.13 there is a revised structure
- ---------------------------------------------------------------------------
- FUNCTION: carrier_detect()
- PURPOSE: determines the state of the modems carrier detect signal
- SYNTAX: result&=@carrier_detect
- OUTPUT: result& - returns 0 if the config tag CDVALID=FALSE (unknown)
- returns 1 for carrier detected
- returns -1 for no carrier detected
- NOTE: STiK does a carrier detect internally (error code -19)
- ---------------------------------------------------------------------------
- FUNCTION: getvstr$()
- PURPOSE: fetches tag settings from the STiK configuration files
- SYNTAX: result$=@getvstr$(tag$)
- INPUT: tag$ - the tag you are wanting the setting of
- OUTPUT: result$ - the setting of the tag you specified
- returns the tag setting if it's found and =something
- returns an empty string if the tag is not set or found
- NOTE: you should probably not invent your own tags
- ---------------------------------------------------------------------------
- FUNCTION: get_err_text$()
- PURPOSE: returns an error code as a string of text
- SYNTAX: result$=@get_err_text$(code&)
- INPUT: code& - the error code you'd like as a string of text
- refer to the error code table below for a list
- OUTPUT: result$ - error code& converted to a string of text
- ---------------------------------------------------------------------------
- FUNCTION: version$()
- PURPOSE: returns the STiK version number
- SYNTAX: result$=@version$
- OUTPUT: result$ - returns the version of STiK as a string of text
- NOTE: format of string will be "00.00"
-
- ===========================================================================
- Connection States:
- 0 - No connection. Null, void, absent, ...
- 1 - Wait for remote request
- 2 - Connect request sent. Await matching request
- 3 - Wait for connection ACK (Listener only ??)
- 4 - Connection is established. Handshake completed
- 5 - Await termination request or acknowledgement
- 6 - Await termination request
- 7 - Await termination request from local user
- 8 - Await termination acknowledge from remote TCP
- 9 - Await acknowledgement of terminate request sent
- 10 - Delay to ensure remote has received term' ACK
- ===========================================================================
- cngetinfo structure:
- uword - protocol TCP or UDP or ... 0 means CIB is not in use
- uword - lport TCP client port (ie: local machine)
- uword - rport TCP server port (ie: remote machine)
- ulong - rhost TCP server IP addr (ie: remote machine)
- ulong - client_ip IP address of client (STiK version 1.13 or higher)
- ===========================================================================
- Error Codes:
- 0 - No error occured ...
- -1 - Output buffer is full (not fatal)
- -2 - No data available (not falal)
- -3 - EOF from remote
- -4 - RST received from remote
- -5 - RST. Other end sent unacceptable pkt
- -6 - Something failed due to lack of memory
- -7 - Connection refused by remote
- -8 - A SYN was received in the window
- -9 - Bad connection handle used
- -10 - The connection is in LISTEN state
- -11 - No free CCB's available
- -12 - No connection matches this packet (TCP)
- -13 - Failure to connect to remote port (TCP)
- -14 - Invalid TCP_close() requested
- -15 - A user function timed out
- -16 - A the connection timed out
- -17 - Can't resolve the hostname
- -18 - Domain name or dotted dec. bad format
- -19 - The modem disconnected
- -20 - Hostname does not exist
- -21 - Resolver Work limit reached
- -22 - No nameservers could be found for query
- -23 - Bad format of DS query
- -24 - Destination unreachable
- -25 - No address records exist for host
- -26 - Routine is unavailable
- 26 - ABS of last error code in this list
- ===========================================================================
- eof
-